﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class Left : System.Web.UI.Page
{
    DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userid"] != null)
        {
            int userid = Convert.ToInt32(Session["userid"].ToString());
            FreeHouse.BLL.UserPower userpower = new FreeHouse.BLL.UserPower(userid);
            dt = userpower.GetMenu();
            DataView dv = new DataView(dt);
            dv.RowFilter = "parentMenuid=0";
            menu.DataSource = dv;
            menu.DataBind();
        }
        else
        {
            Response.Redirect("~/Login.aspx");
        }
    }
    protected void menu_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            Repeater childMenu = (Repeater)e.Item.FindControl("childMenu");
            if (childMenu != null)
            {
                string menuid = ((DataRowView)e.Item.DataItem).Row["menuid"].ToString();
                DataView dv = new DataView(dt);
                dv.RowFilter = "parentMenuid="+menuid;
                childMenu.DataSource = dv;
                childMenu.DataBind();
            }
        }
    }
}
